/*************************************************************************
	> File Name: B3629.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-10 13:16:05
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int calc(int n) {
    int ans = n, temp = 0;
    while (n >= 3) {
        temp = n / 3;
        n %= 3;
        ans += temp;
        n += temp;
    }
    return ans;
}

int binary_search(int val) {
    int head = 1, tail = val, mid;
    while (head < tail) {
        mid = (head + tail) >> 1;
        int cnt = calc(mid);
        if (cnt < val) head = mid + 1;
        else tail = mid;
    }
    return head;
}

int main() {
    int n;
    cin >> n;
    cout << binary_search(n) << endl;
    return 0;
}
